# -*- coding: utf-8 -*-
"""
作者: 肖麒
联系方式：QQ：1505448035
时间: 2025/4/24 15:34
文件作用：
"""
import os
from curl_cffi import requests

headers = {
    "Host": "tos-d-cu-hl.snssdk.com",
    "Authorization": "SpaceKey/lv_pc_text_recognize_cn/0/:version:v2:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NTU0MTMxMzcsInNpZ25hdHVyZUluZm8iOnsiYWNjZXNzS2V5IjoiZmFrZV9hY2Nlc3Nfa2V5IiwiYnVja2V0IjoidG9zLWNuLXYtNDhhNjM3IiwiZXhwaXJlIjoxNzU1NDEzMTM3LCJmaWxlSW5mb3MiOlt7Im9pZEtleSI6Im9VQmdVdVFFaUlCSlVoR2lCS0F3QzBLUzNBZGdhUkFBRWxSbWZYIiwiZmlsZVR5cGUiOiIwIn1dLCJleHRyYSI6eyJhY2NvdW50X3Byb2R1Y3QiOiJ2b2QiLCJibG9ja19tb2RlIjoiIiwiY29udGVudF90eXBlX2Jsb2NrIjoie1wibWltZV9wY3RcIjowLFwibW9kZVwiOjAsXCJtaW1lX2xpc3RcIjpudWxsLFwiY29uZmxpY3RfYmxvY2tcIjpmYWxzZX0iLCJlbmNyeXB0X2FsZ28iOiIiLCJlbmNyeXB0X2tleSI6IiIsInNwYWNlIjoibHZfcGNfdGV4dF9yZWNvZ25pemVfY24iLCJ0b3NfbWV0YSI6IntcIlVTRVJfSFRUUF9IRUFERVJcIjpcIjBcIn0ifX19.J0nhEQvJjYpQS2KS7wpCpS2uziGqKu912Ip-j7Brzjs",
    "Date": "Sat, 16 Aug 2025 06:46:16 GMT",
    "User-Agent": "BDFileUpload(1755326776173)",
    "x-tt-trace-id": "00-b1a105050de41660050c0f48d8820e78-b1a105050de4166001",
    "X-Neptune": "-8|50:51:59:00:09:20:21:30:40:47:49:nf-4:31:39:22:29:00",
    "Content-Type": "application/octet-stream"
}

url = "https://tos-d-cu-hl.snssdk.com/upload/v1/tos-cn-v-48a637/oUBgUuQEiIBJUhGiBKAwC0KS3AdgaRAAElRmfX"
params = {
    "uploadmode": "part",
    "phase": "finish",
    "uploadid": "b73026b5abb24d52ae6d5cc363bb1536"
}

try:
    video_file_path = os.path.join(os.getcwd(), "video.mp4")
    file_size = os.path.getsize(video_file_path)
    headers["Content-Length"] = str(file_size)

    # 读取文件内容为bytes
    with open(video_file_path, "rb") as file:
        file_data = file.read()

    response = requests.post(
        url,
        headers=headers,
        params=params,
        data=file_data,  # 直接使用bytes数据
        timeout=30
    )

    print(f"状态码: {response.status_code}")
    print(f"响应内容: {response.text}")

except FileNotFoundError:
    print("错误: video.mp4文件未找到")
except requests.RequestException as e:
    print(f"请求失败: {str(e)}")
except Exception as e:
    print(f"发生错误: {str(e)}")